﻿'use strict';

(function () {
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
        Templates: {
            Header: function (ctx) {
                return String.format("<ul class='contacts'>");
            },
            Footer: function (ctx) { return String.format("</ul>"); },
            Item: function (ctx) {
                var builder = new Sys.StringBuilder();
                builder.append("<li>");
                builder.append("<table>");
                builder.append(String.format("<tr><td>Name:</td><td>{0}{1}</td></tr>", ctx.RenderFieldByName(ctx, "FirstName"), ctx.RenderFieldByName(ctx, "Title")));
                builder.append(String.format("<tr><td>Company:</td><td>{0}</td></tr>", ctx.RenderFieldByName(ctx, "Company")));
                builder.append(String.format("<tr><td>Email:</td><td>{0}</td></tr>", ctx.RenderFieldByName(ctx, "Email")));
                builder.append(String.format("<tr><td>City:</td><td>{0}</td></tr>", ctx.RenderFieldByName(ctx, "WorkCity")));
                builder.append(String.format("<tr><td>Job Title:</td><td>{0}</td></tr>", ctx.RenderFieldByName(ctx, "JobTitle")));
                builder.append(String.format("<tr><td>Site:</td><td>{0}</td></tr>", ctx.RenderFieldByName(ctx, "WebPage")));
                builder.append("</table>");
                builder.append("</li>");
                return builder.toString();
            }
        }
    });
})();